﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BOHVote.BLL;

namespace BOH.DataManagement
{
    public partial class DictManageList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                if (Request.QueryString["ID"] != null)
                {
                    DeleteDict(Request.QueryString["ID"].ToString());
                }
                if(Request.QueryString["dict"]!=null)
                    BindDict(Request.QueryString["dict"].ToString());
            }
        }


        #region <<  绑定字典  >>
        public void BindDict(string dictName)
        {
            DataSet dst = DictManageClass.LoaddictByValue(dictName);
            RepDict.DataSource = dst;
            RepDict.DataBind();
        }
        #endregion

        #region <<  绑定数据  >>
        protected void RepDict_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                HiddenField hidVale = (HiddenField)e.Item.FindControl("hidenValue");
                DataSet dst = DictManageClass.LoadDataDictByName(hidVale.Value);
                GridView DictViewList = (GridView)e.Item.FindControl("DictViewList");
                DictViewList.DataSource = dst;
                DictViewList.DataBind();
            }
        }
        #endregion

        #region <<  删除数据  >>
        public void DeleteDict(string dictID)
        {
            DictManageClass.DeleteDict(dictID);
        }
        #endregion

        public string getStatus(string value)
        {
            string returnValue = string.Empty;
            if (value == "A")
            {
                returnValue = "激活";
            }
            else {
                returnValue = "<font style='color:red'>未激活</font>";
            }

            return returnValue;
        }


    }
}
